package com.tencent.qf.team.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.tencent.qf.mybatis.pojo.PageRequest;
import com.tencent.qf.mybatis.pojo.PageResult;
import com.tencent.qf.team.dal.TyShareCodeReview;
import com.tencent.qf.team.dao.TyShareCodeReviewMapper;
import com.tencent.qf.team.dto.request.ShareCodeReviewRequest;
import com.tencent.qf.team.service.ShareCodeReviewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ShareCodeReviewServiceImpl implements ShareCodeReviewService {
    @Autowired
    private TyShareCodeReviewMapper tyShareCodeReviewMapper;

    /**
     * 查询分享码浏览记录
     *
     * @param request
     * @return
     */
    @Override
    public PageResult<TyShareCodeReview> queryShareReviews(PageRequest<ShareCodeReviewRequest> request) {
        PageHelper.startPage(request.getPageNo(), request.getPageSize());
        List<TyShareCodeReview> data = tyShareCodeReviewMapper.queryShareReviews(request.getData());
        PageInfo<TyShareCodeReview> pageInfo = new PageInfo(data);
        return PageResult.build(pageInfo);
    }

    /**
     * 查询用户浏览记录
     *
     * @param request
     * @return
     */
    @Override
    public List<TyShareCodeReview> queryViewRecords(ShareCodeReviewRequest request) {
        List<TyShareCodeReview> data = tyShareCodeReviewMapper.queryViewRecords(request);
        return data;
    }
}
